#################################################################################
# Filename: 2_round1_figs.R
# Description: Takes the cleaned round 1 data and creates: 
#   (1) figures generated from round 1 data (main text)
#   (2) figures from round 1 data contained in Appendix C
#       (except Marginal Effects plots, which are in 3_round1_appendices.R)
#################################################################################

### Load library dependencies 
library(tidyverse)
library(broom)
library(DeclareDesign)
library(estimatr)
library(rio)
library(ggplot2)
library(gridExtra)

### ggplot theme
theme_bw1 <- function(base_size = 16, base_family = "") {
  theme_bw(base_size = base_size, base_family = base_family) %+replace%
    theme(
      axis.text.x =       element_text(size = base_size, colour = "black",  hjust = .5 , vjust=1),
      axis.text.y =       element_text(size = base_size , colour = "black", hjust = 0 , vjust=.5 ), # changes position of X axis text
      axis.ticks =        element_line(colour = "grey50"),
      #   axis.title.y =      element_text(size = base_size,angle=90,vjust=.01,hjust=.1),
      legend.position = "none"
    )
}

# Import cleaned data from 1_round1_loaddata
dat <- import("Round_1_clean.Rdata") 


#################################################################################
# (1) Creating round 1 figures in main body of text 
#################################################################################

# Figure 1 left panel 
# Outcome: anger;
# Comparison groups: no video / tv drama / news broadcast
    
    japan <- data.frame(condition=as.character(dat$clip), Y=dat$Q19_1)
    #japan <- japan[!japan$condition=="yongbu",]
    japan$condition <- as.factor(japan$condition)
    levels(japan$condition) <- c("Television Drama", "No video", "News Broadcast")
    japan$condition <- relevel(japan$condition, "No video")
    
    summary_df <-
      japan %>%
      group_by(condition) %>%
      do(tidy(lm_robust(Y ~ 1, data = .))) %>%
      mutate(Y = estimate)
    
    pdf("r1_anger.pdf")
    ggplot(summary_df, aes(condition, Y)) +
      geom_point(size = 3, col="blue") +
      geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0, size=1.5, col="blue") +
      theme_bw1() +
      scale_y_continuous(breaks = seq(2.4, 4.6, length.out = 12)) +
      coord_cartesian(ylim = c(2.5, 4.25)) +
      theme(axis.title.x = element_blank()) +
      ylab("Outcome: Anger [1=No anger... 5=Extremely strong anger]")
    dev.off()



# Figure 2 upper left panel
# Outcome: anti-foreign sentiment;
# Comparison groups: no video / tv drama 

    japan <- data.frame(condition=as.character(dat$clip), Y=dat$antiforeign_pca)
    japan <- japan[!japan$condition=="yongbu",]
    japan$condition <- as.factor(japan$condition)
    levels(japan$condition) <- c("Television Drama", "No video", "News Broadcast")
    japan$condition <- relevel(japan$condition, "No video")
    
    
    summary_df <-
      japan %>%
      group_by(condition) %>%
      do(tidy(lm_robust(Y ~ 1, data = .))) %>%
      mutate(Y = estimate)
    
    pdf("r1_soft_antiforeign.pdf")
    ggplot(summary_df, aes(condition, Y)) +
      geom_point(size = 3, col="blue") +
      geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0, size=1.5, col="blue") +
      theme_bw1() +
      scale_y_continuous(breaks = seq(-1, 1, length.out = 11)) +
      coord_cartesian(ylim = c(-0.4, 0.4)) +
      theme(axis.title.x = element_blank()) +
      ylab("Outcome: Anti-Japanese sentiment index")
    dev.off()
    
    
    
    # Figure 2 lower-left panel
    # Outcome: anti-japanese sentiment index
    # Comparison groups: no video / news broadcast 
    
    japan <- data.frame(condition=as.character(dat$clip), Y=dat$antiforeign_pca)
    japan <- japan[!japan$condition=="leopard",]
    japan$condition <- as.factor(japan$condition)
    levels(japan$condition) <- c("No video", "News Broadcast")
    
    summary_df <-
      japan %>%
      group_by(condition) %>%
      do(tidy(lm_robust(Y ~ 1, data = .))) %>%
      mutate(Y = estimate)
    
    pdf("r1_hard_antiforeign.pdf")
    ggplot(summary_df, aes(condition, Y)) +
      geom_point(size = 3, col="blue") +
      geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0, size=1.5, col="blue") +
      theme_bw1() +
      scale_y_continuous(breaks = seq(-0.4, 0.4, length.out = 11)) +
      coord_cartesian(ylim = c(-0.4, 0.4)) +
      theme(axis.title.x = element_blank()) +
      ylab("Outcome: Anti-Japanese sentiment index")
    dev.off()
    
    
    
# Figure 4
# Outcome: Signed anti-Japan Petition
# comparison groups: no video / tv drama / news broadcast
  
    
    japan <- data.frame(condition=as.character(dat$clip), Y=dat$protest.japan.signed)
    #japan <- japan[!japan$condition=="yongbu",]
    japan$condition <- as.factor(japan$condition)
    levels(japan$condition) <- c("Television Drama", "No video", "News Broadcast")
    japan$condition <- relevel(japan$condition, "No video")
    
    summary_df <-
      japan %>%
      group_by(condition) %>%
      do(tidy(lm_robust(Y ~ 1, data = .))) %>%
      mutate(Y = estimate)
    
    pdf("r1_antiforeign_protest.pdf")
    ggplot(summary_df, aes(condition, Y)) +
      geom_point(size = 3, col="blue") +
      geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0, size=1.5, col="blue") +
      theme_bw1() +
      scale_y_continuous(breaks = seq(0.5, 0.7, length.out = 11)) +
      coord_cartesian(ylim = c(0.5, 0.7)) +
      theme(axis.title.x = element_blank()) +
      ylab("Outcome: Signed anti-Japan petition [0=no, 1=yes]")
    dev.off()
    
    # Figure 5 left panel 
    # Outcome: would protest poor govt service;
    # Comparison groups: no video / tv drama / news broadcast
    
    japan <- data.frame(condition=as.character(dat$clip), Y=dat$protest.gov)
    #japan <- japan[!japan$condition=="yongbu",]
    japan$condition <- as.factor(japan$condition)
    levels(japan$condition) <- c("Television Drama", "No video", "News Broadcast")
    japan$condition <- relevel(japan$condition, "No video")
    
    summary_df <-
      japan %>%
      group_by(condition) %>%
      do(tidy(lm_robust(Y ~ 1, data = .))) %>%
      mutate(Y = estimate)
    
    pdf("r1_gov_protest.pdf")
    ggplot(summary_df, aes(condition, Y)) +
      geom_point(size = 3, col="blue") +
      geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0, size=1.5, col="blue") +
      theme_bw1() +
      scale_y_continuous(breaks = seq(0.1, 0.35, length.out = 6)) +
      coord_cartesian(ylim = c(0.15, 0.35)) +
      theme(axis.title.x = element_blank()) +
      ylab("Outcome: Would protest poor government services [0=no, 1=yes]")
    dev.off()    
    

#################################################################################
# (2) Creating some of the round 1 figures in appendix
#################################################################################
    
# Figure A5, upper-right panel
# Outcome: Hawkishness index
# Comparison groups: no video / tv drama / news broadcast
    
    japan <- data.frame(condition=as.character(dat$clip), Y=dat$militant_pca)
    japan$condition <- as.factor(japan$condition)
    levels(japan$condition) <- c("Television Drama", "No video", "News Broadcast")
    japan$condition <- relevel(japan$condition, "No video")
    
    summary_df <-
      japan %>%
      group_by(condition) %>%
      do(tidy(lm_robust(Y ~ 1, data = .))) %>%
      mutate(Y = estimate)
    
    pdf("r1_hawkish.pdf")
    ggplot(summary_df, aes(condition, Y)) +
      geom_point(size = 3, col="blue") +
      geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0, size=1.5, col="blue") +
      theme_bw1() +
      scale_y_continuous(breaks = seq(-1, 1, length.out = 21)) +
      coord_cartesian(ylim = c(-0.25, 0.25)) +
      theme(axis.title.x = element_blank()) +
      ylab("Outcome: Hawkishness index")
    dev.off()

    
# Figure A5, upper-left panel
# Outcome: Patriotism index
# Comparison groups: no video / tv drama / news broadcast    

    japan <- data.frame(condition=as.character(dat$clip), Y=dat$patriot_pca)
    japan$condition <- as.factor(japan$condition)
    levels(japan$condition) <- c("Television Drama", "No video", "News Broadcast")
    japan$condition <- relevel(japan$condition, "No video")
    
    summary_df <-
      japan %>%
      group_by(condition) %>%
      do(tidy(lm_robust(Y ~ 1, data = .))) %>%
      mutate(Y = estimate)
    
    pdf("r1_patriotic.pdf")
    ggplot(summary_df, aes(condition, Y)) +
      geom_point(size = 3, col="blue") +
      geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0, size=1.5, col="blue") +
      theme_bw1() +
      scale_y_continuous(breaks = seq(-1, 1, length.out = 21)) +
      coord_cartesian(ylim = c(-0.25, 0.25)) +
      theme(axis.title.x = element_blank()) +
      ylab("Outcome: Patriotism index")
    dev.off()
    
    
    
### INDIVIDUAL QUESTION ANSWERS #### 
    
    
# Figure A6, top panel (questions comprising Anti-foreign sentiment index)
    
    pdf("r1_anti_foreign_questions.pdf", width=14, height=4.5)
    par(mfrow = c(1,3),
        oma=c(1,1,0, 0) ,
        mar=c(4,1,4, 1) )
    
    plot(1, xlim=c(-0.6, 0.6), ylim=c(1, 5), axes=F,  xlab="")
    
    
    text(y = 5:1, x= 0.6,par("usr")[1], labels =  c("The Japanese government has not\nsufficiently apologized to China", 
                                                    "Chinese leaders should quickly\ndispatch troops to the Diaoyu islands",
                                                    "Japanese people are warlike",
                                                    "Japanese people are rule-following",
                                                    "Japanese people are true\nto their word"), 
         srt = 0, pos = 2, xpd = TRUE, cex=1.9)
    dat$Q25 <- scale(dat$Q25)
    dat$Q26 <- scale(dat$Q26)
    dat$Q54_1 <- scale(dat$Q54_1)
    dat$Q54_2 <- scale(dat$Q54_2)
    dat$Q54_3 <- scale(dat$Q54_3)
    
    test1 <-  t.test(dat$Q25[dat$clip=="leopard"], dat$Q25[dat$clip=="none"])
    test2 <-  t.test(dat$Q26[dat$clip=="leopard"], dat$Q26[dat$clip=="none"])
    test3 <-  t.test(dat$Q54_1[dat$clip=="leopard"], dat$Q54_1[dat$clip=="none"])
    test4 <-  t.test(dat$Q54_2[dat$clip=="leopard"], dat$Q54_2[dat$clip=="none"])
    test5 <-  t.test(dat$Q54_3[dat$clip=="leopard"], dat$Q54_3[dat$clip=="none"])
    
    
    plot(100, pch=16, xlim=c(-1, 1), ylim=c(1, 5), col="black", xlab="Treatment: TV Drama", ylab="", yaxt= "n", cex.lab=1.6) 
    abline(v=0, col="darkgray", lwd=2)
    
    segments(test1$conf.int[1], 5, test1$conf.int[2], 5, col= 'black', lwd=3)
    segments(test2$conf.int[1], 4, test2$conf.int[2], 4, col= 'black', lwd=3)
    segments(test3$conf.int[1], 3, test3$conf.int[2], 3, col= 'black', lwd=3)
    segments(test4$conf.int[1],2, test4$conf.int[2], 2,  col= 'black', lwd=3)
    segments(test5$conf.int[1], 1, test5$conf.int[2], 1, col= 'black', lwd=3)
    
    points(test1$estimate[1]-test1$estimate[2], 5, pch=16, col= 'black', cex=2)
    points(test2$estimate[1]-test2$estimate[2], 4, pch=16, col= 'black', cex=2)
    points(test3$estimate[1]-test3$estimate[2], 3, pch=16, col= 'black', cex=2)
    points(test4$estimate[1]-test4$estimate[2], 2, pch=16, col= 'black', cex=2)
    points(test5$estimate[1]-test5$estimate[2], 1, pch=16, col= 'black', cex=2)
    
    test1 <-  t.test(dat$Q25[dat$clip=="yongbu"], dat$Q25[dat$clip=="none"])
    test2 <-  t.test(dat$Q26[dat$clip=="yongbu"], dat$Q26[dat$clip=="none"])
    test3 <-  t.test(dat$Q54_1[dat$clip=="yongbu"], dat$Q54_1[dat$clip=="none"])
    test4 <-  t.test(dat$Q54_2[dat$clip=="yongbu"], dat$Q54_2[dat$clip=="none"])
    test5 <-  t.test(dat$Q54_3[dat$clip=="yongbu"], dat$Q54_3[dat$clip=="none"])
    
    
    plot(100, pch=16, xlim=c(-1, 1), ylim=c(1, 5), col="black", xlab="Treatment: Newscast", ylab="", yaxt= "n", cex.lab=1.6) 
    abline(v=0, col="darkgray", lwd=2)
    
    segments(test1$conf.int[1], 5, test1$conf.int[2], 5, col= 'black', lwd=3)
    segments(test2$conf.int[1], 4, test2$conf.int[2], 4, col= 'black', lwd=3)
    segments(test3$conf.int[1], 3, test3$conf.int[2], 3, col= 'black', lwd=3)
    segments(test4$conf.int[1],2, test4$conf.int[2], 2,  col= 'black', lwd=3)
    segments(test5$conf.int[1], 1, test5$conf.int[2], 1, col= 'black', lwd=3)
    
    points(test1$estimate[1]-test1$estimate[2], 5, pch=16, col= 'black', cex=2)
    points(test2$estimate[1]-test2$estimate[2], 4, pch=16, col= 'black', cex=2)
    points(test3$estimate[1]-test3$estimate[2], 3, pch=16, col= 'black', cex=2)
    points(test4$estimate[1]-test4$estimate[2], 2, pch=16, col= 'black', cex=2)
    points(test5$estimate[1]-test5$estimate[2], 1, pch=16, col= 'black', cex=2)
    dev.off()
    

# Figure A6, middle panel (questions comprising patriotism index)
    
    pdf("r1_patriotism_questions.pdf", width=14, height=3.5)
    par(mfrow = c(1,3),
        oma=c(1,1,0, 0) ,
        mar=c(4,1,4, 1) )
    
    plot(1, xlim=c(-0.6, 0.6), ylim=c(1, 4), axes=F,  xlab="")
    
    
    text(y = 4:1, x= 0.6,par("usr")[1], labels =  c("I would prefer to be\na Chinese citizen",
                                                    "Chinese people are warlike",
                                                    "Chinese people are rule-following",
                                                    "Chinese people are true\nto their word"), 
         srt = 0, pos = 2, xpd = TRUE, cex=1.9)
    
    #dat$Q53 <- scale(dat$Q53)
    #dat$Q56_1 <- scale(dat$Q56_1)
    #dat$Q56_2 <- scale(dat$Q56_2)
    #dat$Q56_3 <- scale(dat$Q56_3)
    
    test1 <-  t.test(dat$Q53[dat$clip=="leopard"], dat$Q53[dat$clip=="none"])
    test2 <-  t.test(dat$Q56_1[dat$clip=="leopard"], dat$Q56_1[dat$clip=="none"])
    test3 <-  t.test(dat$Q56_2[dat$clip=="leopard"], dat$Q56_2[dat$clip=="none"])
    test4 <-  t.test(dat$Q56_3[dat$clip=="leopard"], dat$Q56_3[dat$clip=="none"])
    
    
    plot(100, pch=16, xlim=c(-1, 1), ylim=c(1, 4), col="black", xlab="Treatment: TV Drama", ylab="", yaxt= "n", cex.lab=1.6) 
    abline(v=0, col="darkgray", lwd=2)
    
    
    
    segments(test1$conf.int[1], 4, test1$conf.int[2], 4, col= 'black', lwd=3)
    segments(test2$conf.int[1], 3, test2$conf.int[2], 3, col= 'black', lwd=3)
    segments(test3$conf.int[1], 2, test3$conf.int[2], 2, col= 'black', lwd=3)
    segments(test4$conf.int[1],1, test4$conf.int[2], 1,  col= 'black', lwd=3)
    
    points(test1$estimate[1]-test1$estimate[2], 4, pch=16, col= 'black', cex=2)
    points(test2$estimate[1]-test2$estimate[2], 3, pch=16, col= 'black', cex=2)
    points(test3$estimate[1]-test3$estimate[2], 2, pch=16, col= 'black', cex=2)
    points(test4$estimate[1]-test4$estimate[2], 1, pch=16, col= 'black', cex=2)
    
    
    test1 <-  t.test(dat$Q53[dat$clip=="yongbu"], dat$Q53[dat$clip=="none"])
    test2 <-  t.test(dat$Q56_1[dat$clip=="yongbu"], dat$Q56_1[dat$clip=="none"])
    test3 <-  t.test(dat$Q56_2[dat$clip=="yongbu"], dat$Q56_2[dat$clip=="none"])
    test4 <-  t.test(dat$Q56_3[dat$clip=="yongbu"], dat$Q56_3[dat$clip=="none"])
    
    
    plot(100, pch=16, xlim=c(-1, 1), ylim=c(1, 4), col="black", xlab="Treatment: Newscast", ylab="", yaxt= "n", cex.lab=1.6) 
    abline(v=0, col="darkgray", lwd=2)
    
    segments(test1$conf.int[1], 4, test1$conf.int[2], 4, col= 'black', lwd=3)
    segments(test2$conf.int[1], 3, test2$conf.int[2], 3, col= 'black', lwd=3)
    segments(test3$conf.int[1], 2, test3$conf.int[2], 2, col= 'black', lwd=3)
    segments(test4$conf.int[1],1, test4$conf.int[2], 1,  col= 'black', lwd=3)
    
    points(test1$estimate[1]-test1$estimate[2], 4, pch=16, col= 'black', cex=2)
    points(test2$estimate[1]-test2$estimate[2], 3, pch=16, col= 'black', cex=2)
    points(test3$estimate[1]-test3$estimate[2], 2, pch=16, col= 'black', cex=2)
    points(test4$estimate[1]-test4$estimate[2], 1, pch=16, col= 'black', cex=2)
    dev.off()
    
  
# Figure A6, bottom panel (questions comprising hawkishness index)
    
    pdf("r1_hawkish_questions.pdf", width=14, height=3)
    par(mfrow = c(1,3),
        oma=c(1,1,0, 0) ,
        mar=c(4,1,4, 1) )
    
    plot(1, xlim=c(-0.6, 0.6), ylim=c(1, 3), axes=F,  xlab="")
    
    
    text(y = 3:1, x= 0.6,par("usr")[1], labels =  c("China should increase\nnational defense spending",
                                                    "Chinese leaders should quickly\ndispatch troops to the Diaoyu islands",
                                                    "The best way to ensure China's\nsecurity is to increase military strength"), 
         srt = 0, pos = 2, xpd = TRUE, cex=1.9)
    
    #dat$Q53 <- scale(dat$Q53)
    #dat$Q56_1 <- scale(dat$Q56_1)
    #dat$Q56_2 <- scale(dat$Q56_2)
    #dat$Q56_3 <- scale(dat$Q56_3)
    
    test1 <-  t.test(dat$Q28[dat$clip=="leopard"], dat$Q28[dat$clip=="none"])
    test2 <-  t.test(dat$Q26[dat$clip=="leopard"], dat$Q26[dat$clip=="none"])
    test3 <-  t.test(dat$Q52[dat$clip=="leopard"], dat$Q52[dat$clip=="none"])
    
    
    plot(100, pch=16, xlim=c(-1, 1), ylim=c(1, 3), col="black", xlab="Soft Propaganda: TV Drama", ylab="", yaxt= "n", cex.lab=1.6) 
    abline(v=0, col="darkgray", lwd=2)
    
    
    
    segments(test1$conf.int[1], 3, test1$conf.int[2], 3, col= 'black', lwd=3)
    segments(test2$conf.int[1], 2, test2$conf.int[2], 2, col= 'black', lwd=3)
    segments(test3$conf.int[1], 1, test3$conf.int[2], 1, col= 'black', lwd=3)
    
    points(test1$estimate[1]-test1$estimate[2], 3, pch=16, col= 'black', cex=2)
    points(test2$estimate[1]-test2$estimate[2], 2, pch=16, col= 'black', cex=2)
    points(test3$estimate[1]-test3$estimate[2], 1, pch=16, col= 'black', cex=2)
    
    
    
    test1 <-  t.test(dat$Q28[dat$clip=="yongbu"], dat$Q28[dat$clip=="none"])
    test2 <-  t.test(dat$Q26[dat$clip=="yongbu"], dat$Q26[dat$clip=="none"])
    test3 <-  t.test(dat$Q52[dat$clip=="yongbu"], dat$Q52[dat$clip=="none"])
    
    
    plot(100, pch=16, xlim=c(-1, 1), ylim=c(1, 3), col="black", xlab="Hard Propaganda: Newscast", ylab="", yaxt= "n", cex.lab=1.6) 
    abline(v=0, col="darkgray", lwd=2)
    
    
    
    segments(test1$conf.int[1], 3, test1$conf.int[2], 3, col= 'black', lwd=3)
    segments(test2$conf.int[1], 2, test2$conf.int[2], 2, col= 'black', lwd=3)
    segments(test3$conf.int[1], 1, test3$conf.int[2], 1, col= 'black', lwd=3)
    
    points(test1$estimate[1]-test1$estimate[2], 3, pch=16, col= 'black', cex=2)
    points(test2$estimate[1]-test2$estimate[2], 2, pch=16, col= 'black', cex=2)
    points(test3$estimate[1]-test3$estimate[2], 1, pch=16, col= 'black', cex=2)
    
    dev.off()
    
### Figure A10, Effects of propaganda on non-anger emotions 
    
# Sadness    
japan <- data.frame(condition=as.character(dat$clip), Y=dat$Q19_2)
japan$condition <- as.factor(japan$condition)
levels(japan$condition) <- c("Anti-Japan\ntelevision drama", "No video", "Anti-Japan\nnews broadcast")
japan$condition <- relevel(japan$condition, "No video")

summary_df <-
  japan %>%
  group_by(condition) %>%
  do(tidy(lm_robust(Y ~ 1, data = .))) %>%
  mutate(Y = estimate)

pdf("r1_sad.pdf")
ggplot(summary_df, aes(condition, Y)) +
  geom_point(
    data = japan,
    position = position_jitter(width = 0.2, height = 0.1),
    alpha = 0.1
  ) +
  geom_point(size = 3, col="red") +
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0, size=1.5, col="red") +
  theme_bw1() +
  scale_y_continuous(breaks = seq(1, 5, length.out = 5)) +
  coord_cartesian(ylim = c(0.9, 5.1)) +
  theme(axis.title.x = element_blank()) +
  ylab("Outcome: Sad [1=No sadness 5=Extremely strong sadness]")
dev.off()



# Pride 
japan <- data.frame(condition=as.character(dat$clip), Y=dat$Q19_3)
#japan <- japan[!japan$condition=="yongbu",]
japan$condition <- as.factor(japan$condition)
levels(japan$condition) <- c("Anti-Japan\ntelevision drama", "No video", "Anti-Japan\nnews broadcast")
japan$condition <- relevel(japan$condition, "No video")

summary_df <-
  japan %>%
  group_by(condition) %>%
  do(tidy(lm_robust(Y ~ 1, data = .))) %>%
  mutate(Y = estimate)

pdf("r1_pride.pdf")
ggplot(summary_df, aes(condition, Y)) +
  geom_point(
    data = japan,
    position = position_jitter(width = 0.2, height = 0.1),
    alpha = 0.1
  ) +
  geom_point(size = 3, col="red") +
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0, size=1.5, col="red") +
  theme_bw1() +
  scale_y_continuous(breaks = seq(1, 5, length.out = 5)) +
  coord_cartesian(ylim = c(0.9, 5.1)) +
  theme(axis.title.x = element_blank()) +
  ylab("Outcome: Pride [1=No pride 5=Extremely strong pride]")
dev.off()



#Happiness

japan <- data.frame(condition=as.character(dat$clip), Y=dat$Q19_4)
#japan <- japan[!japan$condition=="yongbu",]
japan$condition <- as.factor(japan$condition)
levels(japan$condition) <- c("Anti-Japan\ntelevision drama", "No video", "Anti-Japan\nnews broadcast")
japan$condition <- relevel(japan$condition, "No video")

summary_df <-
  japan %>%
  group_by(condition) %>%
  do(tidy(lm_robust(Y ~ 1, data = .))) %>%
  mutate(Y = estimate)

pdf("r1_happy.pdf")
ggplot(summary_df, aes(condition, Y)) +
  geom_point(
    data = japan,
    position = position_jitter(width = 0.2, height = 0.1),
    alpha = 0.1
  ) +
  geom_point(size = 3, col="red") +
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0, size=1.5, col="red") +
  theme_bw1() +
  scale_y_continuous(breaks = seq(1, 5, length.out = 5)) +
  coord_cartesian(ylim = c(0.9, 5.1)) +
  theme(axis.title.x = element_blank()) +
  ylab("Outcome: Happiness [1=No happiness 5=Extremely strong happiness]")
dev.off()




